<template>
	<view>
		<u-navbar title="用户详情" titleStyle="color:#fff;" :placeholder="false" leftIconColor="#fff" :autoBack="true" bgColor="rgba(0,0,0,0)">
			
		</u-navbar>
		
		<view class="page_bg">
			<image class="bg_img" v-if="anchorInfo.cover" :src="anchorInfo.cover" mode="aspectFill"></image>
			<image class="bg_img" v-else :src="anchorInfo.avatar" mode="aspectFill"></image>
			<view class="my_info">
				<image class="head" :src="anchorInfo.avatar" mode="aspectFill"></image>
				<view class="item">
					<view class="name">
						{{anchorInfo.first_name}}
					</view>
					<view class="text">
						推氪号:{{anchorInfo.t_id}}
					</view>
				</view>
			</view>
		</view>
		
		<view class="my_bg">
			
			<view class="my_detail">
				<view class="info">
					<view class="item">
						<view class="num">{{followData.followed_me}}</view>
						<view class="name">粉丝</view>
					</view>
					<view class="item">
						<view class="num">{{followData.subscribe}}</view>
						<view class="name">订阅</view>
					</view>
					<view class="btn">
						<view class="btn_ico">
							<image class="ico" src="../../static/img/ico_6.png" mode="widthFix"></image>
						</view>
						抖几句MCN
					</view>
				</view>
				
				<view v-if="anchorInfo.biography" class="text">
					{{anchorInfo.biography}}
				</view>
				<view v-else class="text">
					暂无简介...
				</view>
				
			</view>
			
			<view class="btn_two">
				<view v-if="isLike" class="btn hover" @click="clickLike()">
					<view class="name">
						已关注
					</view>
				</view>
				<view v-else class="btn hover" @click="clickLike()">
					<image class="ico" src="../../static/img/ico_add.png" mode="widthFix"></image>
					<view class="name">
						关注
					</view>
				</view>
				<navigator class="btn" url="/pages/vip/vip" hover-class="none">
					<image class="ico" src="../../static/img/ico_7.png" mode="widthFix"></image>
					<view class="name">
						订阅专属会员
					</view>
				</navigator>
			</view>
			
			<view class="all_scene">
				<view class="title">
					所有场景 ({{allLivesData.length}})
				</view>
				<view class="list">
					<view class="item" v-for="(item,index) in allLivesData" @click="clickGotoHome(item.id)" :key="index">
						<image class="ph" :src="item.file" mode="aspectFill"></image>
						<view class="name">
							{{item.name}}
						</view>
						<view v-if="item.is_private != 0" class="lock">
							<image class="ico_8" src="../../static/img/ico_8.png" mode="widthFix"></image>
						</view>
					</view>
				</view>
			</view>
			
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				anchorInfo:{},
				followData:{},
				allLivesData:[],
				isLogin: false,
				userId: '',
				isLike: false,
				anchorId: ''
			}
		},
		onLoad(opt) {
			this.userId = this.userId = uni.getStorageSync('userId');
			this.anchorId = opt.id
			console.log(this.anchorId)
			this.getAigcOtherUserInfo()
			this.getAigcOtherLives()
			this.getStatiscticsData()
			this.getIsFollow()
			this.speedViewAdd({view_user:this.anchorId})
		},
		methods: {
			// 增加观看
			speedViewAdd(postData){
				if(!this.userId)
				{
					return
				}
				uni.$u.http.post('/api/speed_view_add/'+this.userId +'?from=miniprogram', postData).then(res => {
					console.log('增加观看-----',res.data)
					
				}).catch(err => {
					console.log(err)
				})
			},
			// 获取用户个人信息
			getAigcOtherUserInfo(){
				uni.$u.http.get('/api/aigc_other_user_info/?user_id='+this.anchorId+'&from=miniprogram').then(res => {
					console.log('获取用户个人信息-----',res.data)
					this.anchorInfo = res.data.data
				}).catch(err => {
					console.log(err)
				})
			},
			// 点击/取消添加关注
			clickLike(){
				if(this.isLike)
				{
					uni.$u.http.post('api/speed_follow_cancel/'+this.userId+'?from=miniprogram', {follow_id: this.anchorId} ).then(res => {
						console.log('取消关注-----',res.data)
						this.getIsFollow()
					}).catch(err => {
						console.log(err)
					})
				}
				else{
					uni.$u.http.post('api/speed_follow_add/'+this.userId+'?from=miniprogram', {follow_id: this.anchorId} ).then(res => {
						console.log('添加关注-----',res.data)
						this.getIsFollow()
					}).catch(err => {
						console.log(err)
					})
				}
			},
			// 判断是否已关注
			getIsFollow(){
				uni.$u.http.get('/api/speed_my_follow_list/'+this.userId +'?follow_id='+this.anchorId+'&from=miniprogram').then(res => {
					console.log('判断是否已关注-----',res.data)
					if(res.data.data.length == 0){
						console.log('没关注-----')
						this.isLike = false
					}
					else{
						console.log('已关注-----')
						this.isLike = true
					}
				}).catch(err => {
					console.log(err)
				})
			},
			clickGotoHome(id){
				uni.reLaunch({
					url: '/pages/index/index?liveId='+id
				});
			},
			// 用户所有场景
			getAigcOtherLives(){
				uni.$u.http.get('/api/aigc_other_lives_list/?user_id='+this.anchorId+'&from=miniprogram&count=999').then(res => {
					console.log('用户所有场景----',res.data)
					this.allLivesData = res.data.data
				}).catch(err => {
					console.log(err)
				})
			},
			//粉丝/订阅
			getStatiscticsData(){
				uni.$u.http.get('/api/speed_data_statisctics/'+this.anchorId+'?from=miniprogram').then(res => {
					console.log('粉丝/订阅----',res.data)
					this.followData = res.data.data
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.all_scene{
	padding:0 10rpx;
	.title{
		font-size: 26rpx;
		font-weight: 600;
		line-height: 40rpx;
		color: #FFFFFF;
		padding-top: 40rpx;
	}
	.list{
		display: flex;
		align-items: flex-start;
		justify-content: flex-start;
		flex-wrap: wrap;
		margin-left: -30rpx;
		padding-bottom: 30rpx;
		.item{
			width: 203rpx;
			height: 360rpx;
			position: relative;
			margin-top: 30rpx;
			margin-left: 30rpx;
			.lock{
				position: absolute;
				left:0;
				right: 0;
				top:0;
				bottom: 0;
				z-index: 9;
				display: flex;
				align-items: center;
				justify-content: center;
				.ico_8{
					width: 36rpx;
				}
			}
			.ph{
				display: block;
				width: 100%;
				height: 360rpx;
				border-radius: 10rpx;
			}
			.name{
				position: absolute;
				left:0;
				bottom: 0;
				right: 0;
				font-size: 22rpx;
				font-weight: normal;
				line-height: 32rpx;
				text-align: justify;
				color: #FFFFFF;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
				padding:10rpx;
			}
		}
	}
}
.my_bg{
	position: relative;
	z-index: 10;
	background: #1F1F1F;
	border-radius: 30rpx 30rpx 0 0;
	padding:0 30rpx;
	margin-top: -120rpx;
	.btn_two{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding:40rpx 10rpx 0;
		.btn{
			width: 310rpx;
			height: 70rpx;
			border-radius: 35px;
			background: #F9BE01;
			display: flex;
			align-items: center;
			justify-content: center;
			&.hover{
				border: 2rpx solid #F9BE01;
				background: none;
				.name{
					color: #F9BE01;
				}
			}
			.ico{
				width: 40rpx;
				height: 40rpx;
				margin-right: 10rpx;
			}
			.name{
				font-size: 26rpx;
				font-weight: 500;
				line-height: 40rpx;
				text-align: center;
				color: #292D32;
			}
		}
	}
}
.my_detail{
	.text{
		width: 530rpx;
		font-size: 26rpx;
		font-weight: normal;
		line-height: 40rpx;
		color: #FFFFFF;
	}
	.info{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding:40rpx 0;
		.item{
			text-align: center;
			margin-right: 40rpx;
			padding:0 10rpx;
			.num{
				font-size: 30rpx;
				font-weight: 900;
				line-height: 44rpx;
				text-align: justify;
				color:#fff;
				text-align: center;
			}
			.name{
				font-size: 24rpx;
				font-weight: 500;
				line-height: 36rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #A7A7A7;
				text-align: center;
			}
		}
		.btn{
			margin-left: auto;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 28rpx;
			font-weight: 500;
			line-height: 42rpx;
			text-align: justify;
			color:#fff;
			.btn_ico{
				width: 60rpx;
				height: 60rpx;
				border-radius: 10rpx;
				background: #484848;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 16rpx;
				.ico{
					width: 35rpx;
					height: 35rpx;
				}
			}
		}
	}
}
.page_bg{
	width: 100%;
	height: 540rpx;
	overflow: hidden;
	position: relative;
	background: rgba(0, 0, 0, 0);
	background-repeat: no-repeat;
	background-size:100% auto;
	position: relative;
	.bg_img{
		width: 100%;
		opacity: 0.5;
	}
	.my_info{
		width: 100%;
		display: flex;
		align-items: center;
		padding:0 40rpx;
		position: absolute;
		left:0;
		right: 0;
		bottom: 180rpx;
		.head{
			flex-shrink: 0;
			width: 160rpx;
			height: 160rpx;
			border-radius: 50%;
			margin-right: 30rpx;
		}
		.item{
			width: 100%;
			.name{
				font-size: 36rpx;
				font-weight: 600;
				line-height: 54rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #FFFFFF;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
			}
			.text{
				margin-top: 14rpx;
				font-size: 28rpx;
				font-weight: normal;
				line-height: 42rpx;
				text-align: justify;
				letter-spacing: 0px;
				color: #A7A7A7;
				text-shadow: 0px 2rpx 4rpx rgba(0, 0, 0, 0.5);
			}
		}
	}
}
</style>
